<%--
	fileName      : /ctpdemostd/WebContent/logmgmt/logmgmt.jsp
	author        : KFZX-LVSX
	createDate    : 2014-08-20  16:23:26
	lastModifier  : KFZX-LVSX
	lastModifyDate: 2014-08-20  16:23:26
	description   : 请添加描述
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="ctp-tag" prefix="ctp" %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<title><ctp:label key="log_title" /></title>
		<ctp:include items="public,borderlayout,panel,gridlayout,label,button,combobox,datepicker,grid,toolbar,message_ex,validator" />
		<script type="text/javascript">
			var mainBorderlayout;
			var qryPanel;
			var qryGridlayout;
			var dateFrom_dp;
			var dateTo_dp;
			var timeFrom_dp;
			var timeTo_dp;
			var operator_cb;
			var opType_cb;
			var opModule_cb;
			var submitBtn;
			var resetBtn;
			var opToolbar;
			var resultGrid;
			var dateValidator;
		</script>
		<script type="text/javascript">
			function dateValidFunc(caller){
				var flag = true;
				if(caller.getId() === 'dateFrom_dp' && dateTo_dp.getValue() !== ''){
					flag = caller.getValue() > dateTo_dp.getValue() ? false : true; 
					return flag;
				}
				if(caller.getId() === 'dateTo_dp' && dateFrom_dp.getValue() !== ''){
					flag = caller.getValue() < dateFrom_dp.getValue() ? false : true; 
					return flag;
				}
			}

			function timeValidFunc(caller){
				var flag = true;
				var _regExp = /([0-1][0-9]|2[0-4]):[0-5][0-9]/; 
				if(!_regExp.exec(caller.getValue())){
					return false;
				}
				if(caller.getId() === 'timeFrom_dp' && timeTo_dp.getValue() !== ''){
					flag = caller.getValue() > timeTo_dp.getValue() ? false : true; 
					return flag;
				}
				if(caller.getId() === 'timeTo_dp' && timeFrom_dp.getValue() !== ''){
					flag = caller.getValue() < timeFrom_dp.getValue() ? false : true; 
					return flag;
				}
			}

			function qryLog(){
				if(!dateValidator.submitValidate()){
					return;
				}

				var reqData = {
					"opDateMin": dateFrom_dp.getValue(),
					"opDateMax": dateTo_dp.getValue(),
					"opTimeMin": timeFrom_dp.getValue(),
					"opTimeMax": timeTo_dp.getValue(),
					"operatorId": operator_cb.getValue(),
					"opType": opType_cb.getValue(),
					"opModule": opModule_cb.getValue()
				};
				
				var url = '<ctp:url href="logmgmt.flowc" flowActionName="querylog" />';
				resultGrid.loadData(url, reqData);
			}

			function resetFunc(){
				dateFrom_dp.setValue('');
				dateTo_dp.setValue('');
				timeFrom_dp.setValue('');
				timeTo_dp.setValue('');
				operator_cb.setValue('');
				opType_cb.setValue('');
				opModule_cb.setValue('');
			}

			function getDetail(){
				var selectObj = resultGrid.getSelectedData()[0];
				var msbUrl = '<ctp:url href="logmgmt.flowc" flowActionName="logdetail" />&opDate=' + selectObj.opDate
					+ '&opTime=' + selectObj.opTime + '&operatorName=' + selectObj.operatorName
					+ '&operatorIp=' + selectObj.operatorIp + '&opType=' + selectObj.opType_dict
					+ '&opModule=' + selectObj.opModule_dict + '&opItemId=' + selectObj.opItemId
					+ '&description=' + selectObj.description + '&opResult=' + selectObj.opResult
					+ '&logid=' + selectObj.id;
				ctpMSB.win({
					title: '<ctp:label key="log_detail" />',//日志详情
					message: msbUrl,
					width: '600px',
					height: '400px',
					iframe: true
				});
			}
		</script>
		<script type="text/javascript">
			function initUI(){

				dateFrom_dp = new ctp.ui.datepicker({
					id: 'dateFrom_dp',
					width: '100%',
					value: '',
					dateFormat: 'yy-mm-dd',
					validate: 'rules[custom[dateValid],date]'
				});

				dateTo_dp = new ctp.ui.datepicker({
					id: 'dateTo_dp',
					width: '100%',
					value: '',
					dateFormat: 'yy-mm-dd',
					validate: 'rules[custom[dateValid],date]'
				});

				timeFrom_dp = new ctp.ui.datepicker({
					id: 'timeFrom_dp',
					width: '100%',
					value: '',
					onlyTime: true,
					showSecond:false,
					dateFormat: 'hh:mi',
					validate: 'rules[custom[timeValid]]'
				});

				timeTo_dp = new ctp.ui.datepicker({
					id: 'timeTo_dp',
					width: '100%',
					value: '',
					onlyTime: true,
					showSecond:false,
					dateFormat: 'hh:mi',
					validate: 'rules[custom[timeValid]]'
				});

				operator_cb = new ctp.ui.combobox({
					id: 'operator_cb',
					width: '100%',
					defaultItems: {
						text: '<ctp:label key="default_select" />',//--请选择--
						value: '',
						selected: true
					},
					remote: {
						url: '<ctp:url href="logmgmt.flowc" flowActionName="getoperator" />'
					}
				});

				opType_cb = new ctp.ui.combobox({
					id: 'opType_cb',
					width: '100%',
					defaultItems: {
						text: '<ctp:label key="default_select" />',//--请选择--
						value: '',
						selected: true
					},
					items: <ctp:dictdata dicttype="OP_TYPE" dictname="A"/>
				});

				opModule_cb = new ctp.ui.combobox({
					id: 'opModule_cb',
					width: '100%',
					defaultItems: {
						text: '<ctp:label key="default_select" />',//--请选择--
						value: '',
						selected: true
					},
					items: <ctp:dictdata dicttype="OP_MODULE" dictname="A"/>
				});

				submitBtn = new ctp.ui.button({
					id: 'submitBtn',
					text: '<ctp:label key="query" />',//查询
					icon: 'search',
					onClick: qryLog
				});

				resetBtn = new ctp.ui.button({
					id: 'resetBtn',
					text: '<ctp:label key="reset" />',//重置
					icon: 'reload',
					onClick: resetFunc
				});

				qryGridlayout = new ctp.ui.gridlayout({
					id: 'qryGridlayout',
					width: '100%',
					cols: 4,
					defaults: {
						label: {
							width: '100px'
						}
					},
					items: [
						[{
							label: {
								text: '<ctp:label key="opdate_from" />：'//操作日期从
							}, element: dateFrom_dp
						}, {
							label: {
								text: '<ctp:label key="to" />：'//到
							}, element: dateTo_dp
						}, {
							label: {
								text: '<ctp:label key="optime_from" />：'//操作时间从
							}, element: timeFrom_dp
						}, {
							label: {
								text: '<ctp:label key="to" />：'//到
							}, element: timeTo_dp
						}], [{
							label: {
								text: '<ctp:label key="operator" />：'//操作发起人
							}, element: operator_cb
						}, {
							label: {
								text: '<ctp:label key="optype" />：'//操作类型
							}, element: opType_cb
						}, {
							label: {
								text: '<ctp:label key="opmodule" />：'//操作模块
							}, element: opModule_cb
						}], [{
							element: submitBtn,
							align: 'right',
							colspan: 2
						}, {
							element: resetBtn,
							colspan: 2
						}]
					]
				});

				qryPanel = new ctp.ui.panel({
					id: 'qryPanel',
					title: '<ctp:label key="qry_condition" />',//审计查询条件
					width: '100%',
					height: '100%',
					contentPadding: '10px',
					items: [qryGridlayout]
				});

				opToolbar = new ctp.ui.toolbar({
					id: 'opToolbar',
					leftItems: [{
						id: 'qryDetailBtn',
						type: 'button',
						icon: 'search',
						text: '<ctp:label key="qry_detail" />',//查看详情
						disabled: true,
						onClick: getDetail
					}]
				});

				resultGrid = new ctp.ui.grid({
					id: 'resultGrid',
					width: '100%',
					height: '100%',
					title: '<ctp:label key="log_list" />',//审计查询日志列表
					toolbar: opToolbar,
					toolbarPos: 'innertop',
					header: {
						title: [
							[{
								text: ''
							}, {
								text: '<ctp:label key="seq" />'
							}, {
								text: '<ctp:label key="opdate" />'//操作日期
							}, {
								text: '<ctp:label key="optime" />'//操作时间
							}, {
								text: '<ctp:label key="operator" />'//操作发起人
							}, {
								text: '<ctp:label key="operator_ip" />'//发起者客户端IP
							}, {
								text: '<ctp:label key="optype" />'//操作类型
							}, {
								text: '<ctp:label key="opmodule" />'//操作模块
							}, {
								text: '<ctp:label key="op_item_id" />'//操作项ID
							}, {
								text: '<ctp:label key="op_result" />'//操作返回码
							}, {
								text: '<ctp:label key="op_desc" />'//操作描述
							}]
						],
						rowIdFieldName: 'id',
						attr: [
							{colType: 'radiobox'},
							{colType: 'seqnum'},
							{fieldName: 'opDate'},
							{fieldName: 'opTime'},
							{fieldName: 'operatorName'},
							{fieldName: 'operatorIp'},
							{fieldName: 'opType_dict'},
							{fieldName: 'opModule_dict'},
							{fieldName: 'opItemId'},
							{fieldName: 'opResult'},
							{fieldName: 'description'}
						]
					},
					footer: {
						showRows: 15,
						cacheRows: 30,
						showTotalNum: true
					},
					onLoad: function(){
						if(resultGrid.getData().length === 0){
							opToolbar.setDisable('qryDetailBtn', true, 'left');
						}
					},
					onSelect: function(){
						opToolbar.setDisable('qryDetailBtn', false, 'left');
					}
				});
				
				mainBorderlayout = new ctp.ui.borderlayout({
					id: 'mainBorderlayout',
					type: '2E',
					north__items: [qryPanel],
					center__items: [resultGrid],
					renderTo: 'body'
				});

				dateValidator = new ctp.validator({
					id: 'dateValidator',
					promptPosition: 'bottomLeft',
					target: [dateFrom_dp, dateTo_dp, timeFrom_dp, timeTo_dp],
					customRex: {
						'dateValid': {
							isValidateEmpty: false,
							regex: dateValidFunc,
							alertText: '<ctp:label key="correct_date" />'//请输入正确的日期
						},
						'timeValid': {
							isValidateEmpty: false,
							regex: timeValidFunc,
							alertText: '<ctp:label key="correct_time" />'//请输入正确的时间
						}
					}
				});
			}
		</script>
	</head>
	<body onload="initUI();">

	</body>
</html>

<%--
	date        :
	modifyReason:
--%>